// .....................存在期.............................
var ReactDOM = require('react-dom');
var NewView = React.createClass({
    //1.创建阶段
    getDefaultProps: function () {
        console.log(getDefaultProps)
        return {};
    },
    //2.实例化阶段  
    getInitialState: function () {
        console.log("getInitialState");
        return {
            num: 1
        };
    },
    //render之前调用，业务逻辑都应该放在这里，如对state的操作等  
    componentWillMount: function () {
        console.log("componentWillMount");
    },

    //渲染并返回一个虚拟DOM  
    render: function () {
        console.log("render");
        return (
            <div> hello <strong> {this.props.name} </strong>
                <button onClick={this.handleAddNumber}> hello <strong> {this.state.num} </strong></button>
            </div>
        );
    },
    //该方法发生在render方法之后。在该方法中，ReactJS会使用render生成返回的虚拟DOM对象来创建真实的DOM结构  
    componentDidMount:function(){
        console.log("componentDidMount");
        return{};
    },
    //更新阶段
    componentWillReceiveProps:function(){
        console.log("componentWillReceiveProps")
        return{}
    },
    //是否需要更新
    shouldComponentUpdate:function() {  
        console.log("shouldComponentUpdate");  
        return true;  
    },  
    //将要更新
    componentWillUpdate:function() {  
        console.log("componentWillUpdate");  
    },  
    //更新完毕
    componentDidUpdate:function(){
        console.log("componentDidUpDate")
    },
    //销毁阶段
    componentWillUnmount:function(){
        console.log("componentWillunmount")
    },
   // 处理点击事件  
    handleAddNumber:function() {  
        console.log("add num");  
        this.setState({num:this.state.num+1});  
        this.setProps({name:"newName"});  
    }  
});
ReactDOM.render(<NewView name="ReactJS"></NewView>,document.body)